<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>抖好货</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style media="screen">
        .wrap {
            width: 100%;
            padding: 0 15px;
            box-sizing: border-box;
            overflow: hidden;
        }

        .wrap ul {
            width: 100%;
            overflow: hidden;
        }

        .wrap ul li {
            width: 49%;
            background-color: #fff;
            float: left;
            margin-left: 2%;
            margin-top: 10px;
            box-sizing: border-box;
            position: relative;
        }

        .wrap ul li:nth-child(2n+1) {
            margin-left: 0;
        }

        .shop_picture {
            width: 100%;
            height: 223px;
            /*background-color: red;*/
        }
        .shop_picture img{
          width: 100%;
          height: 100%;
          display: block;
        }

        .playBtn {
            width: 25px;
            height: 25px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin-left: -12.5px;
            margin-top: -12.5px;
        }

        .playBtn img {
            width: 100%;
            height: 100%;
            display: block;
        }

        .shdow {
            width: 100%;
            height: 45px;
            position: absolute;
            bottom: 0;
            background: #000000;
            opacity: 0.3;
        }

        .intro {
            width: 100%;
            padding: 0 6px;
            box-sizing: border-box;
            height: 45px;
            position: absolute;
            bottom: 0;
        }

        .intro p {
            width: 100%;
            height: 13px;
            font-size: 12px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 13px;
            box-sizing: border-box;
            margin-top: 7px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .price {
            display: flex;
            margin-top: 7px;
            justify-content: space-between;
        }

        .price_l {
            display: flex;
        }

        .price_l span:first-child {
            font-size: 10px;
            color: #fff;
            height: 15px;
            line-height: 16px;
        }

        .price_l span:last-child {
            font-size: 13px;
            color: #fff;
            height: 15px;
            line-height: 15px;
        }

        .price_r {
            width: 51px;
            height: 15px;
            background: url(../../image/dhh_icon.png) no-repeat;
            background-size: 100% 100%;
            font-size: 12px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #FFFFFF;
            line-height: 15px;
            text-align: center;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="wrap">
            <ul>
                <li v-for='item in dataList' @click='openVideoPlayPage(item.itemid,item.itemshorttitle,item.dyVideoUrl,item.dyVideoTitle)'>
                    <div class="shop_picture"><img :src="item.dynamicImage" alt=""></div>
                    <div class="playBtn"><img src="../../image/play_icon.png" alt=""></div>
                    <div class="shdow"></div>
                    <div class="intro">
                        <p>{{item.itemshorttitle}}</p>
                        <div class="price">
                            <div class="price_l"><span>券后</span><span>￥{{item.itemendprice}}</span></div>
                            <div class="price_r">￥{{item.itemprice}}</div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript">
    apiready = function() {
       console.log(api.pageParam.id);
       vm.init(api.pageParam.id);
       vm.initRefresh()
       vm.bottomLoad()
    }
    var vm = new Vue({
        el: '#app',
        data: {
          dataList: [],
          catId:'',
          mId:'',
          minId:1
        },
        methods: {
            clearData: function() {
                vm.dataList = [];
            },
            openVideoPlayPage: function(itemid,itemshorttitle,dyVideoUrl,dyVideoTitle) {
                cl.openWin({
                    name: 'video_play',
                    pageParam:{
                      itemid:itemid,
                      itemshorttitle:itemshorttitle,
                      dyVideoUrl:dyVideoUrl,
                      dyVideoTitle:dyVideoTitle
                    }
                })
            },
            init: function(catId, isClick) {
                vm.catId = catId;
                // alert(vm.catId)
                if (isClick) {
                    vm.minId = vm.mId;
                } else { // 下拉刷新 或者 初次加载
                    vm.minId = 1;
                }
                // alert(vm.minId)
                api.ajax({
                    url: cl.apiServer + 'tb/getDouYinData',
                    method: 'post',
                    headers: {
                        'Content-Type': 'application/json;charset=utf-8',
                        token:cl.userToken
                    },
                    data: {
                        body: {
                            back:10,
                            catId: catId,
                            minId: vm.minId,
                            version:cl.deviceInfo().appVersion,
                            mobileInfo:cl.systemType()
                        }
                    }
                }, function(ret, err) {
                    if (ret) {
                        console.log(JSON.stringify(ret));
                        if (ret.code == 0) {
                            if (ret.data.data.length >= 10) {
                                vm.no_more = false;
                                vm.dataList = vm.dataList.concat(ret.data.data);
                                vm.mId= ret.data.minId;
                            } else if (ret.data.data.length == 0) {
                                vm.no_more = true;
                            } else {
                                vm.mId= ret.data.minId;
                                vm.dataList = vm.dataList.concat(ret.data.data);
                            }

                        }
                    }
                });
            },
            //下拉刷新
            initRefresh: function() {
                cl.openRefresh(function() {
                    vm.init(vm.catId, false);
                })
            },
            //上拉加载
            bottomLoad: function() {
                cl.scrollBottom(function() {
                    vm.init(vm.catId, true);
                })
            },
        }
    });
</script>

</html>
